Trò chơi Angry Birds trong UNITY Engine
31.727 lượt xem;
- ScaleTweenProperty.cs
- specificTypes /
- properties /
- GoKit /
- Plugins /
- Assets /
- project /
1 using UnityEngine;
2 using System.Collections;
3
4
5 public class ScaleTweenProperty : AbstractVector3TweenProperty
6 {
7 public ScaleTweenProperty( Vector3 endValue, bool isRelative = false ) : base( endValue, isRelative )
8 {}
9
10
11 #region Object overrides
12
13 public override int GetHashCode()
14 {
15 return base.GetHashCode();
16 }
17
18
19 public override bool Equals( object obj )
20 {
21 // if base already determined that we are equal no need to check further
22 if( base.Equals( obj ) )
23 return true;
24
25 // we can be equal if the other object is a ScalePathTweenProperty
26 return obj.GetType() == typeof( ScalePathTweenProperty );
27 }
28
29 #endregion
30
31
32 public override void prepareForUse()
33 {
34 _target = _ownerTween.target as Transform;
35
36 _endValue = _originalEndValue;
37
38 // if this is a from tween we need to swap the start and end values
39 if( _ownerTween.isFrom )
40 {
41 _startValue = _endValue;
42 _endValue = _target.localScale;
43 }
44 else
45 {
46 _startValue = _target.localScale;
47 }
48
49 base.prepareForUse();
50 }
51
52
53 public override void tick( float totalElapsedTime )
54 {
55 var easedTime = _easeFunction( totalElapsedTime, 0, 1, _ownerTween.duration );
56 _target.localScale = GoTweenUtils.unclampedVector3Lerp( _startValue, _diffValue, easedTime );
57 }
58
59 }
2 using System.Collections;
3
4
5 public class ScaleTweenProperty : AbstractVector3TweenProperty
6 {
7 public ScaleTweenProperty( Vector3 endValue, bool isRelative = false ) : base( endValue, isRelative )
8 {}
9
10
11 #region Object overrides
12
13 public override int GetHashCode()
14 {
15 return base.GetHashCode();
16 }
17
18
19 public override bool Equals( object obj )
20 {
21 // if base already determined that we are equal no need to check further
22 if( base.Equals( obj ) )
23 return true;
24
25 // we can be equal if the other object is a ScalePathTweenProperty
26 return obj.GetType() == typeof( ScalePathTweenProperty );
27 }
28
29 #endregion
30
31
32 public override void prepareForUse()
33 {
34 _target = _ownerTween.target as Transform;
35
36 _endValue = _originalEndValue;
37
38 // if this is a from tween we need to swap the start and end values
39 if( _ownerTween.isFrom )
40 {
41 _startValue = _endValue;
42 _endValue = _target.localScale;
43 }
44 else
45 {
46 _startValue = _target.localScale;
47 }
48
49 base.prepareForUse();
50 }
51
52
53 public override void tick( float totalElapsedTime )
54 {
55 var easedTime = _easeFunction( totalElapsedTime, 0, 1, _ownerTween.duration );
56 _target.localScale = GoTweenUtils.unclampedVector3Lerp( _startValue, _diffValue, easedTime );
57 }
58
59 }